package com.lcicl.reggie.common;
/*
  Date: 2023/08/10
  Author: Luochao
  Description:
*/

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;


@Component
public class MyMetaObjectHandler implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {

        metaObject.setValue("createTime", LocalDateTime.now());
        metaObject.setValue("updateTime", LocalDateTime.now());
        metaObject.setValue("createUser", BaseContext.getCurrentId());
        metaObject.setValue("updateUser", BaseContext.getCurrentId());


        //订单
/*        metaObject.setValue("orderTime", LocalDateTime.now());//下单时间
        metaObject.setValue("checkoutTime", LocalDateTime.now());//结账时间
        metaObject.setValue("userId",BaseContext.getCurrentId());//下单用户*/

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        metaObject.setValue("updateTime", LocalDateTime.now());
        metaObject.setValue("updateUser", BaseContext.getCurrentId());
    }
}
